package com.vallis.lotteryonline.util;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    private boolean succese;
    private String msg;
    private T data;


    public Result(boolean success) {
        this(success, null, null);
    }

    public Result(boolean success, T data) {
        this(success, null, data);
    }

    private Result(boolean succese, String msg, T data) {
        this.succese = succese;
        this.msg = msg;
        this.data = data;
    }


    public static <T> Result<T> ok() {
        return new Result<>(true);
    }


    public static <T> Result<T> ok(T data) {
        return new Result<>(true, data);
    }

    public static <T> Result<T> error() {
        return new Result<>(false);
    }


    public static <T> Result<T> error(String message) {
        return new Result<>(false, message, null);

    }


}
